package controllers

import (
	"gin-worked/app/system/service"
	"gin-worked/app/system/validate"
	"gin-worked/work"
	"github.com/gin-gonic/gin"
)

type MenuRoleController struct {
}

// List 角色菜单列表
func (mr MenuRoleController) List(c *gin.Context) {
	var list validate.MenuRoleList

	if err := c.ShouldBind(&list); err != nil {
		work.ReturnResult(c, 0, err.Error(), "")
		return
	}

	param := c.MustGet("params").(map[string]string)
	res := service.MenuRoleList(param["RoleId"])
	work.ReturnResult(c, res.Code, res.Msg, res.Data)
	return
}

func (mr MenuRoleController) Add(c *gin.Context) {
	var add validate.MenuRoleSet

	if err := c.ShouldBind(&add); err != nil {
		work.ReturnResult(c, 0, err.Error(), "")
		return
	}
	param := c.MustGet("params").(map[string]string)
	res := service.MenuRoleSet(param["RoleId"], param["MenuId"])
	work.ReturnResult(c, res.Code, res.Msg, res.Data)
	return

}
